package jdkrel._queue;

import java.util.ArrayDeque;

/**
 * @Author: huangya
 * @Date: 2019/5/28
 * @Description:
 */
public class ArrayDequeDemo {

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
        ArrayDeque<Integer> aDeque = new ArrayDeque<>();
        for (int i = 0; i < arr.length; i++) {
            if ((i & 1) == 0) {
                //如果i是偶数从队头加入，否则从队尾加入
                aDeque.addFirst(arr[i]);
            } else {
                aDeque.addLast(arr[i]);
            }

        }
        while (!aDeque.isEmpty()) {
            aDeque.pollFirst();
            aDeque.pollLast();//此处不严谨但是由于arr的元素恰好是偶数个，本例中也不会出现问题。
        }


        System.out.println("-------------------");


        System.out.println(!ArrayDequeDemo.tryAcquire(1));
    }


    protected static boolean tryAcquire(int arg) {
        throw new UnsupportedOperationException();
    }

}
